Skip to content

chore/update hatch + use dependency groups#3728

Merged
d-v-b merged 10 commits intozarr-developers:mainfrom
d-v-b:chore/update-hatch
Feb 28, 2026
Merged

chore/update hatch + use dependency groups#3728
d-v-b merged 10 commits intozarr-developers:mainfrom
d-v-b:chore/update-hatch

Conversation

@d-v-b
Copy link
Contributor

@d-v-b d-v-b commented Feb 27, 2026

Some updates to our development environment declaration.

  • pin dependencies in CI to unblock broken tests
  • use the official install-hatch action on gha to install hatch instead of using pip. this should speed up our tests.

An additional off-target change that I'm adding here:

  • updates our dependency declarations to declare development dependencies as dependency groups (clearly used for local development, no impact on packaging) instead of optional dependencies (optional deps installable via pip install zarr[option] syntax). Anyone who relied on pip install zarr[tests] to get pytest will need to adjust their imports, but the remediation is simple. The benefit of this change is that we can use dependency-group-aware tools like uv with this project, e.g., uv run --group tests pytest tests.

Very happy to move this into a separate PR if people don't want to mix these concerns. These latter changes require a bit more scrutiny before we should feel comfortable merging.

closes #3726

@github-actions github-actions bot added the needs release notes Automatically applied to PRs which haven't added release notes label Feb 27, 2026
@github-actions github-actions bot removed the needs release notes Automatically applied to PRs which haven't added release notes label Feb 27, 2026
@d-v-b d-v-b marked this pull request as ready for review February 27, 2026 16:19
@d-v-b d-v-b requested a review from a team February 27, 2026 16:19
@d-v-b d-v-b changed the title chore/update hatch chore/update hatch + use dependency groups Feb 27, 2026
@d-v-b
Copy link
Contributor Author

d-v-b commented Feb 27, 2026

fun little detour, turns out our OSX tests in CI were never running with their intended deps (s3fs was missing) because we declared the environment circularly. This PR fixed that, and revealed that our s3 test fixtures are not getting cleaned up correctly on OSX, which raises warnings which fail our tests. This is now fixed in this PR.

@d-v-b d-v-b requested a review from maxrjones February 27, 2026 21:57
@maxrjones
Copy link
Member

fun little detour, turns out our OSX tests in CI were never running with their intended deps (s3fs was missing) because we declared the environment circularly. This PR fixed that, and revealed that our s3 test fixtures are not getting cleaned up correctly on OSX, which raises warnings which fail our tests. This is now fixed in this PR.

this is one of several times we've encountered something similar with the hatch env setup. I think we should consider switching from hatch for environment management. pixi is more explicit in its environment setup and is catching on with friends of zarr (e.g., pydata/xarray#10888).

@d-v-b
Copy link
Contributor Author

d-v-b commented Feb 27, 2026

fun little detour, turns out our OSX tests in CI were never running with their intended deps (s3fs was missing) because we declared the environment circularly. This PR fixed that, and revealed that our s3 test fixtures are not getting cleaned up correctly on OSX, which raises warnings which fail our tests. This is now fixed in this PR.

this is one of several times we've encountered something similar with the hatch env setup. I think we should consider switching from hatch for environment management. pixi is more explicit in its environment setup and is catching on with friends of zarr (e.g., pydata/xarray#10888).

Until we have non-pypi dependencies I'm not sure pixi adds much here -- i'm not sure it would prevent the issues this PR fixes

@maxrjones
Copy link
Member

fun little detour, turns out our OSX tests in CI were never running with their intended deps (s3fs was missing) because we declared the environment circularly. This PR fixed that, and revealed that our s3 test fixtures are not getting cleaned up correctly on OSX, which raises warnings which fail our tests. This is now fixed in this PR.

this is one of several times we've encountered something similar with the hatch env setup. I think we should consider switching from hatch for environment management. pixi is more explicit in its environment setup and is catching on with friends of zarr (e.g., pydata/xarray#10888).

Until we have non-pypi dependencies I'm not sure pixi adds much here -- i'm not sure it would prevent the issues this PR fixes

You're right that the flagship feature of non-pypi deps isn't necessary for zarr-python. At the same time, the circular zarr[test] self-reference pattern is a hatch-specific footgun — pixi doesn't support that pattern at all. Dependencies are declared explicitly per feature/environment, so there's no mechanism to accidentally create a broken self-reference in the first place. This makes environment misconfiguration like the one this PR fixes much harder to introduce silently. #2872 was the other time I discovered various issues with our hatch setup.

It's still mostly a personal preference and while I'd prefer to use pixi across projects rather than hatch for just zarr-python my opinion on this is not very strong so that's fine.

@d-v-b
Copy link
Contributor Author

d-v-b commented Feb 28, 2026

That's a good point about how pixi would prevent dep declaration cycles by design. I wonder if plain uv would offer the same protection. Either way, I do think we are in a good place in this pr thanks to the new dependency group logic. If we have more trouble with hatch in the future we should definitely revisit this.

@d-v-b d-v-b merged commit 974c06c into zarr-developers:main Feb 28, 2026
25 checks passed
@d-v-b d-v-b deleted the chore/update-hatch branch February 28, 2026 04:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

update hatch version in CI

2 participants